package com.qfhd.soft.cjzcore.TaskCenter.CSJ;

import android.app.Activity;
import android.content.Context;
import android.widget.FrameLayout;

import com.qfhd.soft.cjzcore.Listener.CJAdListener;
import com.qfhd.soft.cjzcore.Listener.CJLoadFinishListener;
import com.qfhd.soft.cjzcore.Listener.CJRetListListener;
import com.qfhd.soft.cjzcore.TaskCenter.TTAdManagerHolder;

public class CJCSJsdk {
//    public static String APPID       = "5038180";
//    public static String Message     = "938180884";//信息流
//    public static String SplashId    = "838180942";//开屏
//    public static String RewardVideo = "938180431";//激励视频

    public static String APPID       = "";
    public static String Message     = "";//信息流
    public static String SplashId    = "";//开屏
    public static String RewardVideo = "";//激励视频

    private Context mContext;

    private static CJCSJsdk csJsdk;
    public static CJCSJsdk getInstance(){
        if(csJsdk == null){
            synchronized (CJCSJsdk.class){
                csJsdk  = new CJCSJsdk();
            }
        }
        return csJsdk;
    }

    public void init(Context context){
        mContext    = context;

        //强烈建议在应用对应的Application#onCreate()方法中调用，避免出现content为null的异常
//        TTAdSdk.init(context,
//                new TTAdConfig.Builder()
//                        .appId(CJCSJsdk.APPID)
//                        .useTextureView(false) //使用TextureView控件播放视频,默认为SurfaceView,当有SurfaceView冲突的场景，可以使用TextureView
//                        .appName(mContext.getResources().getString(R.string.app_name))
//                        .titleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK)
//                        .allowShowNotify(true) //是否允许sdk展示通知栏提示
//                        .allowShowPageWhenScreenLock(true) //是否在锁屏场景支持展示广告落地页
//                        .debug(true) //测试阶段打开，可以通过日志排查问题，上线时去除该调用
//                        .directDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI, TTAdConstant.NETWORK_STATE_3G) //允许直接下载的网络状态集合
//                        .supportMultiProcess(false) //是否支持多进程，true支持
//                        //.httpStack(new MyOkStack3())//自定义网络库，demo中给出了okhttp3版本的样例，其余请自行开发或者咨询工作人员。
//                        .build());

        TTAdManagerHolder.init(context);
    }

    public void setAPPID(String appid){
        APPID = appid;
    }

    public void setSplashId(String splashId){
        SplashId = splashId;
    }

    public void setRewardVideoId(String rewardVideoId){
        RewardVideo = rewardVideoId;
    }

    public void setNaviAdId(String naviAdId){
        Message = naviAdId;
    }

    public void showSplash(Activity activity, FrameLayout adContainer, CJLoadFinishListener overListener){
        CJCSJ_Splash.getInstance().begin(activity,adContainer,overListener);
    }

    public void showRewardVidewo(Activity activity, Context context, CJAdListener statusListener){
        CJCSJ_RewardVideo.getInstance().show(activity,context,statusListener);
    }

    public void showNavi(Context context, int width, int height, FrameLayout mExpressContainer, Activity activity, CJAdListener statusListener){
        CJCSJ_Navi.getInstance().getNativeAd(context,width,height,mExpressContainer,activity,statusListener);
    }

    public void showNavi_dialog(Context context, int width, int height, FrameLayout mExpressContainer, Activity activity, CJAdListener statusListener){
        CJCSJ_Navi_dialog.getInstance().getNativeAd(context,width,height,mExpressContainer,activity,statusListener);
    }

    public void getListNaviAd(Context context, int width, int height, CJRetListListener retListener, CJAdListener adListener){
        CJCSJ_List_Navi.getInstance().getAds(context,width,height,retListener,adListener);
    }
}
